package com.xc.domain.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xc.domain.pojo.Address;
import com.xc.domain.query.PageQuery;
import com.xc.domain.service.IAddressService;
import com.xc.simpleReflect.Input.AddressInput;
import com.xc.simpleReflect.Input.UserInput;
import com.xc.simpleReflect.utils.SimpleReflect;
import com.xc.vo.ResultVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author xc
 * @since 2024-05-31
 */
@RestController
@RequestMapping("/address")
@Tag(name = "地址接口")
public class AddressController {
    @Autowired
    private IAddressService addressService;

    @GetMapping("/page")
    @Operation(summary = "分页模糊查询")
    public ResultVO<List<Address>> page(AddressInput addressInput, PageQuery pageQuery) {
        QueryWrapper queryWrapper = SimpleReflect.parseWrap(addressInput, Address.class);
        Page<Address> addPage = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
        IPage page = addressService.page(addPage, queryWrapper);
        return ResultVO.success(page.getRecords());
    }
}
